﻿namespace EyeOpen.SearchFile.Windows
{
	using System.IO;
	using System.Windows.Forms;
	using EyeOpen.IO;

	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		private void SearchLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			var directoryInfo = new DirectoryInfo(@"c:\temp");

			new AsyncWorker()
				.RunWorkerAsync(
					fileNameTextBox.Text,
					p =>
						{
							var fileName = p;

							var fileInfo = directoryInfo.Search(fileName, new TextBoxLogger(searchingTextBox));

							if (fileInfo == null)
							{
								MessageBox.Show("File not found.");
								return;
							}

							MessageBox.Show("File path: " + fileInfo.FullName);
						});
		}
	}
}
